<?php
$g4_path = "../"; 
require_once ($g4_path.'common.php');

if(!$member['mb_id']) {
    echo 'Login required<br>';
    echo 'click <a href="http://neao2007.elegantcoder.com/bbs/login.php?url=%2Fadmin%2F_makeCourseOrder.php">here for login (id : student1, pass : 1234)'; 
    exit;    
}

if($_POST) {
    
    $sql = "SET student = '".$_POST['student']."', tel1='".$_POST['tel1']."', tel2='".$_POST['tel2']."', course='".$_POST['course']."', teacher='".$_POST['teacher']."', bank='".$_POST['bank']."', bankname='".$_POST['bankname']."', price='".$_POST['price']."'"; 

    $sql = "INSERT INTO course_order ".$sql;
    sql_query($sql);

}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?php echo $title?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<form method=POST>
<input type=hidden name=student value="<?php echo $member['mb_no']; ?>" />
<input type=hidden name=teacher id="teacher" value="" />

<br/><br/>

학생이름 : <?php echo $member['mb_name']; ?><br/>
휴대전화 : <input type=text name=tel1 value="<?php echo $member['tel1']; ?>"><br/>
일반전화 : <input type=text name=tel2 value="<?php echo $member['tel2']; ?>"><br/>
<br/>
강사부터 고르기 / 강의부터 고르기 (미구현)<br/><br/>
강의선택 :
<select name="course" onChange="javascript:handleCode(this)">
<option value="">== 선택해주세요 ==</option>
<?php

    $sql = "SELECT c.no as no, c.price as price, c.name as name, c.teacher as teachercode, m.mb_name as teachername FROM course c, g4_member m WHERE c.check = '1' AND m.mb_no = c.teacher";  
    $_res = sql_query($sql);

    while($res = sql_fetch_array($_res)) {
        echo '<option teacher="'.$res['teachercode'].'" value="'.$res['no'].'">';
        echo $res['name'].' (강사명:'.$res['teachername'].'/'.$res['price'].'원)</option>'; 
    }
?>
<script>
    function handleCode(node) {
        document.getElementById('teacher').value = node.options[node.selectedIndex].getAttribute('teacher');
        return true;
    }

</script>
</select>
<br/>
입금은행 : <input type=text name="bank"><br/>
입금액 : <input type=text name="price"><br/>
입금자명 : <input type=text name="bankname"><br/>
<input type=submit>
</form>
